Repository navigation
semantics: a Semantics around a control names the control's own node (ADR-0407) - #3269
Merged
Merged
Conversation
… takes it, first wins Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
… its Flutter counterpart is a container Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
…nd a container button keeps its own Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
…R-0322 §6 and ADR-0240 §1 state the new rule Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
…rm is its constructor; the records state the joined identifier Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
…07 states the identifier refusal, the disabled toggle and the row template Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
…odes; the identifier docs of the controls state the joined node Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
… disabled node above still absorbs them Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
…node, a button's or a chip's too; ADR-0407 lists where it departs from Flutter Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Vanya · project thread
Summary
A control is now named one way, whatever it is:
Semantics::labelaround it names the control's own node. Flutter 3.50.1 gets this right for a switch (Semantics(label: …, child: Switch(…))is one switch named by the label) and wrong for a button:ButtonStyleButton,RawMaterialButtonandRawChipare containers, so a label around one is a second node with no action above the button, and a screen reader stops twice (applications record it; ADR-0407 links two reports). Flutter's naming builders are uneven too:Checkbox.semanticLabel, none onSwitchorRadio. FLUI built every control'sDescription(ADR-0322 §1) asSemantics::container(true), so even the switch case made a nameless control, which is why #3264 needed asemantic_labelper widget. ADR-0407 fixes it at the two seams every control goes through:Description::new(role)is an annotation,Description::container(role)isSemantics(container: true),Description::merging(role)isMergeSemantics, chosen by the constructor and held in one private enum. Toggles,CupertinoButton, a cupertino tab item, a tappable carousel item and an enabledListTileare annotations;RawButton, theButtonStyleButtonfamily, the FAB, chips and a chip's delete button are containers; tabs and navigation destinations merge. Each cites its line in flutter/flutter@3.50.1.Semanticsthat holds only a control names the control's node (sole_control_it_namesin the assembly,SemanticsConfiguration::absorb_enclosing). An annotation control joins it as in Flutter; a container control's node takes it, where Flutter forms the label's node above. The label reads first ("Send Go"). ASemanticsover a control and other content stays above them, and a button stays apart from the content beside it.absorbcarries an identifier, first wins, as Flutter's does (semantics.dart:6954); two different identifiers are two nodes, and a disabled control does not join a node that offers a user action.ADR-0407 has a table of every place it departs from Flutter and why (a labelled button, the one naming path, a disabled
ListTile, two identifiers, an identifier alone, a disabled control beside an action). ADR-0322 §6, ADR-0240 §1 and §4, ADR-0332 §4 andflui-semantics' ARCHITECTURE state the new rule. The builders that only set a control's name and are still onmain(Checkbox::semantic_label,Slider::label) are listed indocs/gaps.mdand go in the next small PR;Disclosure::label, which replaces the name its content gives, stays.Cost:
Descriptionstays at most 16 bytes. No element, render node or allocation is added: the fold reuses the node the control already forms. The heap-counted perf targets offlui,flui-rendering,flui-widgets,flui-materialandflui-cupertinopass underFLUI_PERF_BASELINE=checkin release with the CI feature set. The assembly reads one more condition per annotated node, so main's callgrind lane may move instructions slightly.Verification
cargo fmt --all; clippy--all-targets -D warningson flui-semantics, flui-rendering, flui-widgets, flui-material and flui-cupertino; tests of those and of flui-testing and flui-objectsflui-rendering'san_annotation_around_a_control_alone_names_the_controls_nodefails with the fold removed and with the label read after the button's (left: "Go Send");named_by_semantics::a_label_around_a_control_names_the_controls_own_node(Switch, disabled Switch, Checkbox, Radio, enabled ListTile, ElevatedButton, FAB, FilterChip) fails with a toggle a container, with the fold removed and withabsorbdropping the identifier;raw_button::a_label_around_a_raw_button_names_the_buttons_nodefails with the fold removed;a_disabled_toggle_does_not_join_a_row_that_tapsfails with the disabled refusal removed.SemanticsConfiguration::absorb_enclosingis new influi-semantics, called by the assembly.Descriptionlives in the#[doc(hidden)]__private::node.docs/gaps.mdchangelog.d/claude-project-thread-f2wym8.mdExpectations changed
flui-semanticsthe_identifier_is_exported_unannounced_unmerged_and_no_boundaryis renamed…_no_boundary_and_joins_first_wins. Its "a parent absorbing the node takes its label, not its identifier" claim is now "a parent with none takes the identifier, and not as text", plus a first-wins claim. The old expectation stated the rule ADR-0407 replaces.flui-renderingan_identifier_names_only_the_node_its_configuration_formsis renamedan_identifier_names_the_node_its_configuration_forms_or_joins. The group now carriesnote-idfrom its absorbed contributor, for the same reason. The bare identifier now sits before the note, so the test would see a bare identifier that wrongly joined.named_by_semantics::a_label_around_a_container_control_is_a_node_above_itandraw_button::a_label_around_a_raw_button_is_a_node_above_itare replaced by the rows and the test above: they pinned Flutter's two-node shape, which ADR-0407 §2 now refuses.Review
Read at a89bce8 by
review-before-mergeat tierfable(seven readers, a Fable judge). No mutation run (cargo-gamma is not installed in this container); each fix below was taken out by hand and its test seen to fail. The design read (mode: "design") was not run separately, because of the project's two-round limit; the records lens read the ADRs. Seven findings were confirmed and none rejected. Answered at e58f4d7:absorbmerge table, the docs ofSemantics::identifier,MergeSemantics::identifierandRenderMergeSemantics::set_identifier, ADR-0332 §4,changelog.d/semantics-identifier.md, the content-roles fragment and the flui-driver spec evidence all state the joined identifier now.rgfor the old phrasings finds nothing.can_absorbandcan_joinrefuse a configuration named otherwise than the node or a sibling, and that configuration keeps its own node and id. This is a departure from Flutter, which keeps the first id and drops the other; it is recorded in ADR-0407's counterparts table. AMergeSemanticsstill takes everything. Pinned bya_toggle_keeps_its_identifier_whatever_names_the_node_above_it(fails with the refusal removed) and by a new claim in the flui-semantics identifier table.enabled: falseinto the node above, while ListTile departs. Kept on purpose, with the reason now in ADR-0407 §1. The node that absorbs a disabled toggle reads as that toggle, which is what the label around it names. The tile's departure exists because a tile is a row of content whose state would otherwise read as the list's. Pinned by the "a disabled Switch" row.named_by_semantics.rs, plusbutton::a_label_around_a_button_names_the_buttons_own_node(cupertino) andraw_button::a_label_around_a_raw_button_is_a_node_above_it(widgets). Each was seen to fail with its control flipped to the other form. The carousel item and the cupertino tab item get no row, because their parent forces separate nodes either way (ADR-0407 §1).container()guarding against downgrading a merge. Fixed by shape: the form is a constructor (Description::new,container,merging), so no later call can change it.Round 2 read the fixes at e58f4d7 with the same workflow and tier (the last round the project allows). The judge confirmed five findings and two nits, and rejected three (a disabled ListTile, the chip forms, carousel and tab rows), each ruled out by a line. Answered at 29ff2a8, read by the author alone:
can_joincompared identifiers without thehas_been_annotatedguardcan_absorbhas, so a bare-identifier sibling was refused. Fixed by one owner of the rule:keeps_apart, read by both and guarded byhas_been_annotated.InkWellrow made the row read as disabled and refuse its tap. Fixed at the seam: a disabled configuration does not join a node that offers a user action, as a descendant or a sibling. A node that is itself disabled still absorbs the actions below it, as before (an_ordinary_merge_keeps_its_actions). Pinned bya_disabled_toggle_does_not_join_a_row_that_taps, which fails with the refusal removed, and a claim in the identifier table.identifierbuilders of the toggles,CupertinoButtonandEditableTextstill said "the node the control forms". Fixed: each states the node its semantics form or join.semantic_labelit no longer depends on. Fixed.MergeSemanticsare left for the next small PR (the configuration table coverscan_join); the stale "as before" wording went with the rewrite.After round 2, the owner asked that this not copy Flutter where Flutter is weak. The change at fe7753d (the labelled-container fold, the one naming path, ADR-0407 rewritten with its departures table) came after both rounds the project allows, so it was read by the author alone against "Before each push": no user code or allocation on the new path; the fold applies only to an annotation that is none of a boundary, a merge, a merge part, a node with explicit children or a node the clips hide, whose one child fragment is a formed node of a content-named role, and that
can_absorbaccepts (so a second tap, a second identifier or a disabled control beside an action still splits); a lazy item's stamped position moves onto the control's node; nested annotations (a tooltip and a label around one button) fold one after the other. The automated review of the pull request is the second reader for it.Architecture
edge-exceptionsorreach-exceptionsentryflui-materialgains the dev-dependencyflui-protocol(workspace), forRolein the scenario tester's finders; flui-material: buttons and selection controls run on the scenario tester; Switch, Radio and a chip's delete button can be named #3264 adds the same lineNotes
SwitchandRadioare named in its tests withSemantics::label.Chip::delete_button_labelstays: it is the delete button's tooltip, visible in Flutter (deleteButtonTooltipMessage).https://claude.ai/code/session_01EqfW4FAhVS5dwwxVx5vRGK
Generated by Claude Code